<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script src="https://apps.bdimg.com/libs/angular-route/1.3.13/angular-route.js"></script>
</head>
<body>
<div ng-app="fapp"> 
    <div id="navigation">  
      <a href="#/home">Home</a>
      <a href="#/about">About</a>
    </div>
      
    <div ng-view="">
    </div>
  </div>
  
  <script type="text/javascript">
  
  var myapp=angular.module("fapp",['ngRoute']);
  myapp.config(function ($routeProvider) {
	  $routeProvider.
	    when('/home', {
	        templateUrl: 'task3.html',
	        controller: 'c1'
	    }).
	    when('/about', {
	        templateUrl: 'task4.html',
	        controller: 'c2'
	    })
  });
	    myapp.controller("c1",function($scope){
	    	$scope.rs=[
	    		{name:'张三',status:'未开始',story:"1"},
	    		{name:'张五',status:'完成',story:"2"},
	    		{name:'张六',status:'关闭',story:"3"},
	    		{name:'张九',status:'进行中',story:"4"},
	    		{name:'张八',status:'未开始',story:"1"}
	    		]
	    	
	    	$scope.update=function(index){
	    		var id="edit"+index
	    		$scope[id]=true;
	    	}
	    	
	    	$scope.update2=function(t,index){
	    		//$scope.rs[index].name=t.name;
	    		var id="edit"+index
	    		$scope[id]=false;
	    	}
	    	
	    	$scope.deleteRecord=function(t,index){
	    		//splice方法   js数组删除某一个元素， 第一个参数是起点的下标，第二个参数是删除元素的个数
	    		$scope.rs.splice(index,1);
	    	}
	    	
	    	$scope.cancelUpdate=function(index){
	    		var id="edit"+index
	    		$scope[id]=false;
	    	}
	    	
	    });
	    	 myapp.controller("c2",function($scope){
	 	    	$scope.rs=[
	 	    		{name:'张三',status:'未开始',story:"1"},
	 	    		{name:'张五',status:'完成',story:"2"},
	 	    		{name:'张六',status:'关闭',story:"3"},
	 	    		{name:'张九',status:'进行中',story:"4"},
	 	    		{name:'张八',status:'未开始',story:"1"}
	 	    		]
	 	    	
	 	    	$scope.update=function(index){
	 	    		var id="edit"+index
	 	    		$scope[id]=true;
	 	    	}
	 	    	
	 	    	$scope.update2=function(t,index){
	 	    		//$scope.rs[index].name=t.name;
	 	    		var id="edit"+index
	 	    		$scope[id]=false;
	 	    	}
	 	    	
	 	    	$scope.deleteRecord=function(t,index){
	 	    		//splice方法   js数组删除某一个元素， 第一个参数是起点的下标，第二个参数是删除元素的个数
	 	    		$scope.rs.splice(index,1);
	 	    	}
	 	    	
	 	    	$scope.cancelUpdate=function(index){
	 	    		var id="edit"+index
	 	    		$scope[id]=false;
	 	    	}
  });
  
  </script>
</body>
</html>